﻿@model Tasks.UI.Models.Power.AssignRolePowerModel
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>权限分配管理</title>
    <link href="@Config.GetCssResourcePath("main.css")" rel="stylesheet" type="text/css" />
    <link href="@Config.GetCssResourcePath("table.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Scripts/jquery-impromptu.3.1.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-impromptu.3.1.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/global.js")" type="text/javascript"></script>
    <style type="text/css">
        .ulAction
        {
            list-style: none;
        }
        .ulAction li
        {
            width: 100px;
            float: left;
        }
    </style>
    <script type="text/javascript">

        $(function () {

            var groups = new Array('基础', '地接', '组团', '订单', '产品', '公司');
            for (var i = 0; i < groups.length; i++) {
                var rows = $(".moduleContainer tr[label*='" + groups[i] + "']");
                if (rows.length == 0)
                    $("#" + groups[i]).hide();
            }

            selectPowerGroup($(".tabsClass li").eq(0), "全部");

        })

        //全选 
        function checkall() {
            var obj = $(".CheckAll");
            obj.attr("checked", true);
        }

        //反选
        function uncheckall() {
            $(".CheckAll").each(function () {
                if ($(this).attr("checked")) {
                    $(this).attr("checked", false);
                }
                else {
                    $(this).attr("checked", true);
                }
            });
        }

        function selectPowerGroup(src, groupName) {

            if (groupName == '全部') {
                $(".moduleContainer tr").show();
            }
            else {
                $(".moduleContainer tr").hide();
                $(".moduleContainer tr[label*='" + groupName + "']").show();
            }


            if (src != undefined) {
                $(".tabsClass li").removeClass("selected");
                $(src).addClass("selected");
            }

            setDialogHeight();
        }

    </script>
</head>
<body>
    <div id="container">
        @using (Html.BeginForm())
        {
           
            <div class="navTitle">
                <ul>
                    <li class="Home SecondLast"><a href="#">
                        <div class="HomeIcon">
                        </div>
                        <font><font>权限分配</font></font></a></li><li class="Last"><span><font><font>角色权限:@Model.RoleName</font></font></span></li>
                </ul>
            </div>
            <h1>
                <font class="">角色权限 : @Model.RoleName</font>
            </h1>
            <p class="intro">
                <font>该窗口功能是为 （@Model.RoleName） 分配权限，分配权限还需指定可以访问哪个系统，否则将无法打开该系统。 </font>
            </p> 
            
            
            @Html.OutputMessage(Model.Message, Model.MessageType)
            <ul class="tabsClass">
                <li id="全部" onclick="selectPowerGroup(this,'全部')"><a href="javascript:void(0)" class="selected">
                    <span>全部</span> </a></li>
                <li id="基础" onclick="selectPowerGroup(this,'基础')"><a href="javascript:void(0)"><span>
                    基础模块</span></a></li>
                <li id="地接" class="" onclick="selectPowerGroup(this,'地接')"><a href="javascript:void(0)">
                    <span>地接模块</span></a></li>
                <li id="组团" class="" onclick="selectPowerGroup(this,'组团')"><a href="javascript:void(0)">
                    <span>组团模块</span></a></li>
                <li id="订单" class="" onclick="selectPowerGroup(this,'订单')"><a href="javascript:void(0)">
                    <span>交易模块</span></a></li>
                <li id="产品" class="" onclick="selectPowerGroup(this,'产品')"><a href="javascript:void(0)">
                    <span>产品模块</span></a></li>
                <li id="公司" class="" onclick="selectPowerGroup(this,'公司')"><a href="javascript:void(0)">
                    <span>公司模块</span></a></li>
                <li id="套票" class="gongshi" onclick="selectPowerGroup(this,'套票')"><a href="javascript:void(0)">
                    <span>套票模块</span></a></li>
            </ul>
            <div class="clear">
            </div>
            
            <div>
                @foreach (App app in Model.Apps)
                {
                    if (Model.RoleApps.Count(t => t.AppID == app.AppID) > 0)
                    {
                    <input type="checkbox" checked="checked" name="AppID" id="app_@(app.AppID)" value="@app.AppID" class="CheckAll"/>
                    }
                    else
                    {
                    <input type="checkbox"  name="AppID" id="app_@(app.AppID)" value="@app.AppID" class="CheckAll"/>
                    }
                    <label for="app_@(app.AppID)">
                        @app.Name</label>
            
                }
            </div>
            <table class="tblStyle1" style="table-layout: fixed; width: 100%;">
                <thead>
                    <tr label="">
                        <th style="width: 150px">
                            @Html.HiddenFor(t => t.RoleID)
                            功能模块
                        </th>
                        <th align="left">
                            操作权限
                        </th>
                    </tr>
                </thead>
                <tbody class="moduleContainer">
                    @foreach (PowerModule module in Model.ModuleList)
                    {
                        <tr label="@module.Label">
                            <td class="c">
                                @module.Name
                                <input id="ModuleID" name="ModuleID" type="hidden" value="@module.ModuleID"/>
                            </td>
                            <td style="text-align: left;">
                                <ul class="ulAction">
                                    @{
                                                                                     IList<PowerAction> actions = Model.ActionList.Where(t => t.ModuleID == module.ModuleID).ToList();
                                    }
                                    @foreach (PowerAction action in actions)
                                    {
                                        <li>
                                            @if (Model.srtActions.IndexOf(("," + action.ActionID.ToString()) + ",") != -1)
                                            {
                                                <input type="checkbox" checked="checked" name="ActionID" id="act_@(action.ActionID)" value="@action.ActionID" class="CheckAll"/>
                                            }
                                            else
                                            {
                                                <input type="checkbox" name="ActionID"  id="act_@(action.ActionID)" value="@action.ActionID" class="CheckAll"/>
                                            }
                                            <label for="act_@(action.ActionID)" title="@action.Dspt">
                                                @action.Name</label>
                                        </li>
                                    }
                                </ul>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>

            <a href="javascript:void(0)" onclick="checkall()">全选</a>
            <a href="javascript:void(0)" onclick="uncheckall()">反选</a>
            <div class="BottomBtn">
                <button class="blue" type="submit">
                    <span>保存权限</span></button></div>
        }
    </div>
</body>
</html>
